package com.kjj;

import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class OptionView {
    private KjjActivity mActivity;
    private ProductList mList;

    public OptionView(KjjActivity activity, ProductList list) {
	mActivity = activity;
	mList = list;
	init();
    }

    public boolean init() {
	return true;
    }

    public void resetView() {

    }

    public boolean startView() {
	mActivity.setContentView(R.layout.option);
	EditText editText = (EditText) mActivity
		.findViewById(R.id.optionPhoneNumEditText);
	editText.setHint(mActivity.getString(R.string.optionPhoneNum)
		+ ProductList.phoneNum);
	editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
	    @Override
	    public void onFocusChange(View v, boolean hasFocus) {
		if (!hasFocus) {
		    EditText editText = (EditText) v;
		    ProductList.phoneNum = editText.getText().toString();
		    editText.setText("");
		    editText.setHint(mActivity
			    .getString(R.string.optionPhoneNum)
			    + ProductList.phoneNum);
		}
	    }
	});
	Button returnButton = (Button) mActivity
		.findViewById(R.id.optionReturnButton);
	returnButton.setOnClickListener(new Button.OnClickListener() {

	    @Override
	    public void onClick(View v) {
		mActivity.switchView(KjjActivity.POST_VIEW);
	    }

	});
	Button feedbackButton = (Button) mActivity
		.findViewById(R.id.optionEnsureButton);
	feedbackButton.setOnClickListener(new Button.OnClickListener() {

	    @Override
	    public void onClick(View v) {
		Communication.sendFeedback(((EditText) mActivity
			.findViewById(R.id.optionFeedbackEditText)).getText()
			.toString());
	    }

	});
	return true;
    }
}
